package com.vm.dao.mobile.impl;

import org.apache.log4j.Logger;

import com.vm.action.mobile.AppDetailAction;
import com.vm.common.Page;
import com.vm.common.SqlConstant;
import com.vm.dao.BaseDAOImpl;
import com.vm.dao.mobile.base.IAppDetailDao;
import com.vm.entity.AppDetail;
import com.vm.log4j.CustomizeLog4j;

public class AppDetailDaoImpl extends  BaseDAOImpl<AppDetail, Integer> implements IAppDetailDao {
	private static Logger log = CustomizeLog4j.getLogger(AppDetailDaoImpl.class);
	
	public AppDetailDaoImpl() {
		setEntityClass(AppDetail.class);
	}
	
	public Page<AppDetail> getPageBySectionId(Integer sectionId,Integer pageSize,Integer currentPage){
		Page<AppDetail> page = null;
		String countHql = SqlConstant.getAppCountbySectionIdSql();
		String hql = SqlConstant.getAppbySectionIdSql();
		Object[] params = new Object[]{sectionId};
		try {
			page = this.page(hql, countHql, params, pageSize, currentPage);
		} catch (Exception e) {
			log.error("AppDetailDaoImpl getPageBySectionId is error");
		}
		return page;
	}
	
	public Integer getCountBySectionId(Integer sectionId){
		Integer count = 0;
		String countHql = SqlConstant.getAppCountbySectionIdSql();
		Object[] params = new Object[]{sectionId};
		try {
			count = this.getTotalCount(countHql, params);
		} catch (Exception e) {
			log.error("AppDetailDaoImpl getCountBySectionId is error");
		}
		return count;
	}
}
